<!DOCTYPE html>
<html>
{include file="public/head"}

<body>
    {include file="public/nav"} {include file="public/nav-2"}
    <!-- 分割线 -->
    <div class="layui-container fly-marginTop">
        <div class="fly-panel fly-panel-user" pad20="">
            <div class="layui-tab layui-tab-brief" lay-filter="user">
                <ul class="layui-tab-title">
                    <!-- <li><a href="UserLogin.html">登入</a></li> -->
                    <li class="layui-this">重置密码</li>
                </ul>
                <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form layui-form-pane">
                            <form method="post" id="myform" action="">
                                <div class="layui-form-item">
                                    <div class="layui-form-item">
                                        <label for="L_pass" class="layui-form-label">邮箱</label>
                                        <div class="layui-input-inline">
                                            <input type="text" id="email" name="email" value="{$email}" class="layui-input layui-disabled"  readonly>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label for="L_pass" class="layui-form-label">新密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" name="password1" required="" lay-verify="required" autocomplete="off" class="layui-input">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux">密码长度为6~18位</div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label for="L_pass" class="layui-form-label">确认密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" name="password2" required="" lay-verify="required" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <input type="hidden" name="key" value="{$key}">
                                    <div class="layui-form-item">
                                        <button class="layui-btn" lay-filter="update" lay-submit>提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 分割线 -->
    {include file="public/foot"}
    </body>
    <script>
    layui.use(['form', 'jquery','layer'], function() {
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;
        form.on('submit(update)', function(data) {
            console.log(data.field);
            if (data.field['password1'] != data.field['password2']) {
                layer.msg('两次密码输入不一致！');
                return false;
            }
            if(data.field['password1'].length<6||data.field['password1'].length>18) {
                layer.msg('密码长度为6~18位！');
                return false;
            }
            $.ajax({
                url:"{:url('web/user/use_email_update_password')}",
                data: data.field,
                type: 'post',
                dataType: 'JSON',
                success:function(res) {
                    // console.log(res);
                    if(res.result==false) {
                        layer.msg(res.msg);
                    } else if(res.result==true){
                        window.location.href="{:url('web/user/Updateing')}";
                    }
                },
                error:function() {

                }
            });
            return false;
        });

    });
    </script>
</html>